package com.kuafu.latte.transport;

import com.kuafu.latte.exchange.ByteUtil;
import com.kuafu.latte.exchange.Message;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;

public class MessageEncoder extends MessageToByteEncoder<Message> {


    @Override
    protected void encode(ChannelHandlerContext ctx, Message msg, ByteBuf out) throws Exception {
        byte[] bytes = ByteUtil.objectToByte(msg);
        out.writeBytes(bytes);
    }
}
